feat(python-sdk): add extension instrumentation#2096
Conversation
Summary of ChangesHello @pilartomas, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the observability of the Python SDK by introducing OpenTelemetry-based instrumentation, specifically targeting the A2A extension components. It provides a robust framework for tracing functions and class methods, allowing for automatic generation of spans that capture the flow and performance of operations within agent extensions. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces OpenTelemetry-based instrumentation for extensions, which is a great addition for observability. The core of this is the new agentstack_sdk/util/telemetry.py file, which provides trace_function and trace_class decorators.
My review focuses on the correctness and robustness of these new utilities. I've identified a couple of important issues:
- A bug in how
asyncio.CancelledErroris handled, which could lead to incomplete trace data. - An issue with tracing methods decorated with
@asynccontextmanager, likelifespan, which would result in incorrect trace spans.
I've provided suggestions to fix these issues. Additionally, I've pointed out a couple of areas for improvement in code quality. Overall, this is a solid feature, and with these adjustments, it will be even more robust.
d06c7d1 to
7f6cfa9
Compare
|
@gemini have a look |
There was a problem hiding this comment.
Code Review
This pull request introduces OpenTelemetry-based instrumentation for SDK extensions and enhances security by utilizing pydantic.SecretStr and a new SecureBaseModel for automatic redaction of sensitive data. However, a critical security vulnerability was identified where sensitive information, including tool arguments, command-line arguments, and URLs, is logged in plain text to telemetry backends. This poses a significant risk of exposing secrets, particularly due to missing redaction logic in the Approval and MCP extensions and an insufficient redaction policy in the base extension server's telemetry logging. Additionally, there are minor areas for improvement for code clarity and simplification.
ecd2b9a to
a719275
Compare
Signed-off-by: Tomas Pilar <thomas7pilar@gmail.com>
868b5ab to
0c987e0
Compare
Signed-off-by: Tomas Pilar thomas7pilar@gmail.com
Summary
This PR injects tracing into all extensions, using the same approach as A2A python SDK. It provides some additional tracing for certain extensions.
It also ensures that secrets are redacted before sending them to telemetry.
Linked Issues
closes #1975
Documentation
If this PR adds new feature or changes existing. Make sure documentation is adjusted accordingly. If the docs is not needed, please explain why.